package wangxu

import (
	"context"
	"github.com/beherochuling/beesoft_api/app/dao"
	"github.com/beherochuling/beesoft_api/app/model/entity"
)

func NewLetsviewConnection(ctx context.Context) *letsviewConnection {
	return &letsviewConnection{
		ctx: ctx,
	}
}

type letsviewConnection struct {
	ctx context.Context
}

func (r *letsviewConnection) GetByCode(code uint64) *entity.LetsviewConnections {
	var item *entity.LetsviewConnections

	err := dao.LetsviewConnections.Ctx(r.ctx).
		Where(dao.LetsviewConnections.Columns().Fd, code).
		Scan(&item)
	if err != nil {
		panic(err)
	}

	return item
}
func (r *letsviewConnection) GetByFd(fd int64) *entity.LetsviewConnections {
	var item *entity.LetsviewConnections

	err := dao.LetsviewConnections.Ctx(r.ctx).
		Where(dao.LetsviewConnections.Columns().Fd, fd).
		Scan(&item)
	if err != nil {
		panic(err)
	}

	return item
}
